@ECHO OFF
cls
cd\
cd "C:\_Eclipse Workspace\wolfram-google\trunk"
SET current_directory=%cd%
SET extension_name=Wolfram Google


set dateAppend=%date:~0,4%-%date:~5,2%-%date:~8,2%
set sourceFileExt=xpi
set branchName=Main

set /a fileCounter=1

:checkTarget
If exist "Downloads\Archive\%extension_name%-%branchName%-%dateAppend%-%fileCounter%.%sourceFileExt%" (goto :incrementCounter) else (goto :createZip)
goto :createZip

:incrementCounter
set /a fileCounter=%fileCounter%+1
goto :checkTarget

:createZip
"C:\Program Files\7-Zip\7z.exe" a -tzip -r "Downloads\Archive\%extension_name%-%branchName%-%dateAppend%-%fileCounter%.%sourceFileExt%" "%cd%\wolframgoogle\*" -x@excludeFromBuild.txt
goto :Archive

:Archive
cd Downloads
del "%extension_name%-%branchName%.%sourceFileExt%"
copy "Archive\%extension_name%-%branchName%-%dateAppend%-%fileCounter%.%sourceFileExt%" "%extension_name%-%branchName%.%sourceFileExt%"
cd..
goto :EOF


GOTO :EOF
